<template>
	<view>
		<view class="none" v-if="isPage && list.length == 0">
			<i class="iconfont iconquesheng"></i>
			<text>暂无数据~</text>
		</view>
		<view>
			<view class="problemItem" v-for="(item,index) in problem" :key="index">
				<view class="infoItem" @tap="item.isShow =! item.isShow">
					<view class="infoItem-title"><text>{{index >= 9 ? index+1 : '0'+(index+1)}}</text>{{item.title}}</view>
					<i class="iconfont" :class="item.isShow ? 'iconbottom':'iconright'"></i>
				</view>
				<view v-show="item.isShow" class="infoItem-text">{{item.content}}</view>
			</view>
			<uni-load-more v-if="problem.length >= 18" :status="status" :content-text="contentText" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				problem: [],
				page: 1,
				reload: true,
				isPage: false,
				status: 'more',
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '—— 没有更多了 ——',
					contentnot: "没数据"
				}
			}
		},onPullDownRefresh() {
			this.publicFunc();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.status = 'loading';
			this.page = this.page + 1;
			var _this = this;
			setTimeout(function() {
				_this.getList();
			}, 500);
		},
		onShow() {
			this.publicFunc();
		},
		methods: {
			// 获取地址列表
			getList() {
				this.$shopApi.apiPost('font/faq/infos',{page: this.page,limit:20}).then(res=>{
					if (res.data.code == 200 && res.data.data.list && res.data.data.list.length > 0) {
						var list = res.data.data.list;
						list.forEach(item => {
							item['isShow'] = false;
						})
						this.problem = this.reload ? list : this.problem.concat(list);
						this.reload = false;
						this.status = 'more';
					} else {
						if (this.reload) {
							this.problem = [];
							this.isPage = true;
						} else {
							this.status = 'noMore';
						}
					}
				})
			},
			// 公用方法
			publicFunc() {
				this.page = 1;
				this.reload = true;
				this.isPage = false;
				this.list = [];
				this.getList();
			}
		}
	}
</script>

<style>
	page{
		padding-bottom: 50upx;
	}
	.problemItem {
		background-color: #FFFFFF;
		border-top: 2upx solid #E7E7E7;
	}
	.problemItem:first-child {
		border: none;
	}

	.infoItem {
		color: #333333;
		height: auto;
		min-height: 60upx;
		padding: 20upx 30upx;
		justify-content: space-between;
	}

	.infoItem-title {
		width: 93%;
		display: flex;
		line-height: 44upx;
		white-space: normal;
	}

	.infoItem-title text {
		color: #AE7A1F;
		font-size: 20upx;
		background: #E6B873;
		border-radius: 50%;
		height: 44upx;
		text-align: center;
		min-width: 44upx;
		margin-right: 20upx;
	}

	.infoItem-text {
		color: #999999;
		font-size: 24upx;
		padding: 0 90upx 30upx;
		line-height: 1.6;
	}
</style>
